package cn.actoncode.boot.framework.common.exception.enums;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Map;

/**
 * 讯飞小程序错误码
 *
 * @author bin
 */
@Getter
public enum XfyunErrorMsgEnum {

    /**
     * access_token 过期
     */
    CODE_10105(10105, "未通过服务端校验"),

    ;

    private final int code;
    private final String msg;

    XfyunErrorMsgEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    static final Map<Integer, String> valueMap = Maps.newHashMap();

    static {
        for (XfyunErrorMsgEnum value : XfyunErrorMsgEnum.values()) {
            valueMap.put(value.code, value.msg);
        }
    }

    /**
     * 通过错误代码查找其中文含义.
     */
    public static String findMsgByCode(int code) {
        return valueMap.getOrDefault(code, null);
    }
}
